---
description: "Reference for Nitric's Node.js library - Returns a reference to a known version of a secret."
---

# Node.js - secret.version()

<Note>
  This is reference documentation for the Nitric Node.js SDK. To learn about
  Secrets in Nitric start with the [Secrets docs](/secrets).
</Note>

Returns a reference to a known version of a secret.

```javascript
import { secret } from '@nitric/sdk'

const keyRef = secret('encryptionKey').allow('access')

const keyVersionRef = keyRef.version('the-version-id')
```

## Parameters

<Properties>
  <Property name="version" required type="string">
    The version ID. This value is returned from [secret.put()](./secret-put).
  </Property>
</Properties>

## Examples

### Return a reference to a known secret version

```javascript
import { secret } from '@nitric/sdk'

const keyRef = secret('encryptionKey').allow('access')

const keyVersionRef = keyRef.version('the-version-id')
```

### Access the value of a known secret version

```javascript
import { secret } from '@nitric/sdk'

const keyRef = secret('encryptionKey').allow('access')

const keyValue = await keyRef.version('the-version-id').access()

keyValue.asString()
```

### See also

- [secret.version().access()](./secret-version-access)
